package com.njthird.busi.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.njthird.common.annotation.Log;
import com.njthird.common.core.controller.BaseController;
import com.njthird.common.core.domain.AjaxResult;
import com.njthird.common.enums.BusinessType;
import com.njthird.busi.domain.BusiCusorders;
import com.njthird.busi.service.IBusiCusordersService;
import com.njthird.common.utils.poi.ExcelUtil;
import com.njthird.common.core.page.TableDataInfo;

/**
 * 客户订单Controller
 * 
 * @author njthird
 * @date 2020-08-19
 */
@RestController
@RequestMapping("/busi/cusorders")
public class BusiCusordersController extends BaseController
{
    @Autowired
    private IBusiCusordersService busiCusordersService;

    /**
     * 查询客户订单列表
     */
    @PreAuthorize("@ss.hasPermi('busi:cusorders:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusiCusorders busiCusorders)
    {
        startPage();
        List<BusiCusorders> list = busiCusordersService.selectBusiCusordersList(busiCusorders);
        return getDataTable(list);
    }

    /**
     * 导出客户订单列表
     */
    @PreAuthorize("@ss.hasPermi('busi:cusorders:export')")
    @Log(title = "客户订单", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BusiCusorders busiCusorders)
    {
        List<BusiCusorders> list = busiCusordersService.selectBusiCusordersList(busiCusorders);
        ExcelUtil<BusiCusorders> util = new ExcelUtil<BusiCusorders>(BusiCusorders.class);
        return util.exportExcel(list, "cusorders");
    }

    /**
     * 获取客户订单详细信息
     */
    @PreAuthorize("@ss.hasPermi('busi:cusorders:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(busiCusordersService.selectBusiCusordersById(id));
    }

    /**
     * 新增客户订单
     */
    @PreAuthorize("@ss.hasPermi('busi:cusorders:add')")
    @Log(title = "客户订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusiCusorders busiCusorders)
    {
        return toAjax(busiCusordersService.insertBusiCusorders(busiCusorders));
    }

    /**
     * 修改客户订单
     */
    @PreAuthorize("@ss.hasPermi('busi:cusorders:edit')")
    @Log(title = "客户订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusiCusorders busiCusorders)
    {
        return toAjax(busiCusordersService.updateBusiCusorders(busiCusorders));
    }

    /**
     * 删除客户订单
     */
    @PreAuthorize("@ss.hasPermi('busi:cusorders:remove')")
    @Log(title = "客户订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(busiCusordersService.deleteBusiCusordersByIds(ids));
    }
}
